home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14664 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: wdl1.wdl.loral.com!dst17!mab
  2. From: mab@dst17.wdl.loral.com (Mark A Biggar)
  3. Newsgroups: comp.lang.ada,comp.lang.c++
  4. Subject: Re: some questions re. Ada/GNAT from a C++/GCC user
  5. Date: 1 Apr 1996 16:17:13 GMT
  6. Organization: Loral Western Development Labs
  7. Message-ID: <4jovi9$c2b@wdl1.wdl.loral.com>
  8. References: <wnewmanDoxrCp.DKv@netcom.com> <Dp1oAw.7Cz@world.std.com> <ROGOFF.96Mar29163036@sccm.Stanford.EDU>
  9. NNTP-Posting-Host: dst17.wdl.loral.com
  10.  
  11. In article <ROGOFF.96Mar29163036@sccm.Stanford.EDU> rogoff@sccm.stanford.edu writes:
  12. >   > Why doesn't Ada 95 allow declarations to be interspersed with ordinary
  13. >   > statements as C++ does?  (Or does it?  _Ada as a Second Language_ is a
  14. >   > big book!)  It seems to me that the C++ approach is a small but
  15. >   > definite win.  Does it interact very badly somehow with all those
  16. >   > guarantees on elaboration order?
  17. >
  18. >   To intersperse declarations, you have to use a block_statement, like
  19. >   this:
  20. >
  21. >       for I in Some_String'Range loop -- I wish I could easily use an iterator here ;-)
  22. >       declare
  23. >           X: constant Character := Some_String(I);
  24. >       begin
  25. >           ...
  26. >       end;
  27. >       end loop;
  28. >
  29. >   To me, the "declare", "begin", and "end" are just useless verbosity.
  30. >   I prefer the C++ rule.
  31. >
  32. >Yes, this seems needlessly verbose. Any Ada guru have a good reason why it has 
  33. >to be this way?
  34.  
  35. Yeah, 2 reasons.  The first goes clear back to the original Ada Strawman
  36. documnt which calls for a clear distinction between declarations and code
  37. statements.  The second reason is that is also the method of wraping an
  38. exception handler around soem arbitary piece of code:
  39.  
  40. for I in Some_String'Range loop 
  41.     declare
  42.         X: constant Character := Some_String(I);
  43.     begin
  44.         ...
  45.     exception
  46.         when ... ;
  47.     end;
  48. end loop;
  49.  
  50.  
  51. --
  52. Mark Biggar
  53. mab@wdl.loral.com
  54.  
  55.